﻿using System;

namespace HslCommunication
{
	/// <summary>
	/// 操作结果的泛型类，允许带一个用户自定义的泛型对象，推荐使用这个类
	/// </summary>
	/// <typeparam name="T">泛型类</typeparam>
	// Token: 0x02000015 RID: 21
	public class OperateResult<T> : OperateResult
	{
		/// <summary>
		/// 实例化一个默认的结果对象
		/// </summary>
		// Token: 0x06000109 RID: 265 RVA: 0x00005A52 File Offset: 0x00003C52
		public OperateResult()
		{
		}

		/// <summary>
		/// 使用指定的消息实例化一个默认的结果对象
		/// </summary>
		/// <param name="msg">错误消息</param>
		// Token: 0x0600010A RID: 266 RVA: 0x00005A5C File Offset: 0x00003C5C
		public OperateResult(string msg) : base(msg)
		{
		}

		/// <summary>
		/// 使用错误代码，消息文本来实例化对象
		/// </summary>
		/// <param name="err">错误代码</param>
		/// <param name="msg">错误消息</param>
		// Token: 0x0600010B RID: 267 RVA: 0x00005A67 File Offset: 0x00003C67
		public OperateResult(int err, string msg) : base(err, msg)
		{
		}

		/// <summary>
		/// 用户自定义的泛型数据
		/// </summary>
		// Token: 0x17000049 RID: 73
		// (get) Token: 0x0600010C RID: 268 RVA: 0x00005A73 File Offset: 0x00003C73
		// (set) Token: 0x0600010D RID: 269 RVA: 0x00005A7B File Offset: 0x00003C7B
		public T Content { get; set; }

		/// <summary>
		/// 返回一个检查结果对象，可以进行自定义的数据检查。<br />
		/// Returns a check result object that allows you to perform custom data checks.
		/// </summary>
		/// <param name="check">检查的委托方法</param>
		/// <param name="message">检查失败的错误消息</param>
		/// <returns>如果检查成功，则返回对象本身，如果失败，返回错误信息。</returns>
		// Token: 0x0600010E RID: 270 RVA: 0x00005A84 File Offset: 0x00003C84
		public OperateResult<T> Check(Func<T, bool> check, string message = "All content data check failed")
		{
			bool flag = !base.IsSuccess;
			OperateResult<T> result;
			if (flag)
			{
				result = this;
			}
			else
			{
				bool flag2 = check(this.Content);
				if (flag2)
				{
					result = this;
				}
				else
				{
					result = new OperateResult<T>(message);
				}
			}
			return result;
		}

		/// <summary>
		/// 返回一个检查结果对象，可以进行自定义的数据检查。<br />
		/// Returns a check result object that allows you to perform custom data checks.
		/// </summary>
		/// <param name="check">检查的委托方法</param>
		/// <returns>如果检查成功，则返回对象本身，如果失败，返回错误信息。</returns>
		// Token: 0x0600010F RID: 271 RVA: 0x00005AC4 File Offset: 0x00003CC4
		public OperateResult<T> Check(Func<T, OperateResult> check)
		{
			bool flag = !base.IsSuccess;
			OperateResult<T> result;
			if (flag)
			{
				result = this;
			}
			else
			{
				OperateResult operateResult = check(this.Content);
				bool flag2 = !operateResult.IsSuccess;
				if (flag2)
				{
					result = OperateResult.CreateFailedResult<T>(operateResult);
				}
				else
				{
					result = this;
				}
			}
			return result;
		}

		/// <summary>
		/// 指定接下来要做的是内容，当前对象如果成功，就返回接下来的执行结果，如果失败，就返回当前对象本身。<br />
		/// Specify what you want to do next, return the result of the execution of the current object if it succeeds, and return the current object itself if it fails.
		/// </summary>
		/// <param name="func">等待当前对象成功后执行的内容</param>
		/// <returns>返回整个方法链最终的成功失败结果</returns>
		// Token: 0x06000110 RID: 272 RVA: 0x00005B0B File Offset: 0x00003D0B
		public OperateResult Then(Func<T, OperateResult> func)
		{
			return base.IsSuccess ? func(this.Content) : this;
		}

		/// <summary>
		/// 指定接下来要做的是内容，当前对象如果成功，就返回接下来的执行结果，如果失败，就返回当前对象本身。
		/// Specify what you want to do next, return the result of the execution of the current object if it succeeds, and return the current object itself if it fails.
		/// </summary>
		/// <typeparam name="TResult">泛型参数</typeparam>
		/// <param name="func">等待当前对象成功后执行的内容</param>
		/// <returns>返回整个方法链最终的成功失败结果</returns>
		// Token: 0x06000111 RID: 273 RVA: 0x00005B24 File Offset: 0x00003D24
		public OperateResult<TResult> Then<TResult>(Func<T, OperateResult<TResult>> func)
		{
			return base.IsSuccess ? func(this.Content) : OperateResult.CreateFailedResult<TResult>(this);
		}

		/// <summary>
		/// 指定接下来要做的是内容，当前对象如果成功，就返回接下来的执行结果，如果失败，就返回当前对象本身。<br />
		/// Specify what you want to do next, return the result of the execution of the current object if it succeeds, and return the current object itself if it fails.
		/// </summary>
		/// <typeparam name="TResult1">泛型参数一</typeparam>
		/// <typeparam name="TResult2">泛型参数二</typeparam>
		/// <param name="func">等待当前对象成功后执行的内容</param>
		/// <returns>返回整个方法链最终的成功失败结果</returns>
		// Token: 0x06000112 RID: 274 RVA: 0x00005B42 File Offset: 0x00003D42
		public OperateResult<TResult1, TResult2> Then<TResult1, TResult2>(Func<T, OperateResult<TResult1, TResult2>> func)
		{
			return base.IsSuccess ? func(this.Content) : OperateResult.CreateFailedResult<TResult1, TResult2>(this);
		}

		/// <summary>
		/// 指定接下来要做的是内容，当前对象如果成功，就返回接下来的执行结果，如果失败，就返回当前对象本身。<br />
		/// Specify what you want to do next, return the result of the execution of the current object if it succeeds, and return the current object itself if it fails.
		/// </summary>
		/// <typeparam name="TResult1">泛型参数一</typeparam>
		/// <typeparam name="TResult2">泛型参数二</typeparam>
		/// <typeparam name="TResult3">泛型参数三</typeparam>
		/// <param name="func">等待当前对象成功后执行的内容</param>
		/// <returns>返回整个方法链最终的成功失败结果</returns>
		// Token: 0x06000113 RID: 275 RVA: 0x00005B60 File Offset: 0x00003D60
		public OperateResult<TResult1, TResult2, TResult3> Then<TResult1, TResult2, TResult3>(Func<T, OperateResult<TResult1, TResult2, TResult3>> func)
		{
			return base.IsSuccess ? func(this.Content) : OperateResult.CreateFailedResult<TResult1, TResult2, TResult3>(this);
		}

		/// <summary>
		/// 指定接下来要做的是内容，当前对象如果成功，就返回接下来的执行结果，如果失败，就返回当前对象本身。<br />
		/// Specify what you want to do next, return the result of the execution of the current object if it succeeds, and return the current object itself if it fails.
		/// </summary>
		/// <typeparam name="TResult1">泛型参数一</typeparam>
		/// <typeparam name="TResult2">泛型参数二</typeparam>
		/// <typeparam name="TResult3">泛型参数三</typeparam>
		/// <typeparam name="TResult4">泛型参数四</typeparam>
		/// <param name="func">等待当前对象成功后执行的内容</param>
		/// <returns>返回整个方法链最终的成功失败结果</returns>
		// Token: 0x06000114 RID: 276 RVA: 0x00005B7E File Offset: 0x00003D7E
		public OperateResult<TResult1, TResult2, TResult3, TResult4> Then<TResult1, TResult2, TResult3, TResult4>(Func<T, OperateResult<TResult1, TResult2, TResult3, TResult4>> func)
		{
			return base.IsSuccess ? func(this.Content) : OperateResult.CreateFailedResult<TResult1, TResult2, TResult3, TResult4>(this);
		}

		/// <summary>
		/// 指定接下来要做的是内容，当前对象如果成功，就返回接下来的执行结果，如果失败，就返回当前对象本身。<br />
		/// Specify what you want to do next, return the result of the execution of the current object if it succeeds, and return the current object itself if it fails.
		/// </summary>
		/// <typeparam name="TResult1">泛型参数一</typeparam>
		/// <typeparam name="TResult2">泛型参数二</typeparam>
		/// <typeparam name="TResult3">泛型参数三</typeparam>
		/// <typeparam name="TResult4">泛型参数四</typeparam>
		/// <typeparam name="TResult5">泛型参数五</typeparam>
		/// <param name="func">等待当前对象成功后执行的内容</param>
		/// <returns>返回整个方法链最终的成功失败结果</returns>
		// Token: 0x06000115 RID: 277 RVA: 0x00005B9C File Offset: 0x00003D9C
		public OperateResult<TResult1, TResult2, TResult3, TResult4, TResult5> Then<TResult1, TResult2, TResult3, TResult4, TResult5>(Func<T, OperateResult<TResult1, TResult2, TResult3, TResult4, TResult5>> func)
		{
			return base.IsSuccess ? func(this.Content) : OperateResult.CreateFailedResult<TResult1, TResult2, TResult3, TResult4, TResult5>(this);
		}

		/// <summary>
		/// 指定接下来要做的是内容，当前对象如果成功，就返回接下来的执行结果，如果失败，就返回当前对象本身。<br />
		/// Specify what you want to do next, return the result of the execution of the current object if it succeeds, and return the current object itself if it fails.
		/// </summary>
		/// <typeparam name="TResult1">泛型参数一</typeparam>
		/// <typeparam name="TResult2">泛型参数二</typeparam>
		/// <typeparam name="TResult3">泛型参数三</typeparam>
		/// <typeparam name="TResult4">泛型参数四</typeparam>
		/// <typeparam name="TResult5">泛型参数五</typeparam>
		/// <typeparam name="TResult6">泛型参数六</typeparam>
		/// <param name="func">等待当前对象成功后执行的内容</param>
		/// <returns>返回整个方法链最终的成功失败结果</returns>
		// Token: 0x06000116 RID: 278 RVA: 0x00005BBA File Offset: 0x00003DBA
		public OperateResult<TResult1, TResult2, TResult3, TResult4, TResult5, TResult6> Then<TResult1, TResult2, TResult3, TResult4, TResult5, TResult6>(Func<T, OperateResult<TResult1, TResult2, TResult3, TResult4, TResult5, TResult6>> func)
		{
			return base.IsSuccess ? func(this.Content) : OperateResult.CreateFailedResult<TResult1, TResult2, TResult3, TResult4, TResult5, TResult6>(this);
		}

		/// <summary>
		/// 指定接下来要做的是内容，当前对象如果成功，就返回接下来的执行结果，如果失败，就返回当前对象本身。<br />
		/// Specify what you want to do next, return the result of the execution of the current object if it succeeds, and return the current object itself if it fails.
		/// </summary>
		/// <typeparam name="TResult1">泛型参数一</typeparam>
		/// <typeparam name="TResult2">泛型参数二</typeparam>
		/// <typeparam name="TResult3">泛型参数三</typeparam>
		/// <typeparam name="TResult4">泛型参数四</typeparam>
		/// <typeparam name="TResult5">泛型参数五</typeparam>
		/// <typeparam name="TResult6">泛型参数六</typeparam>
		/// <typeparam name="TResult7">泛型参数七</typeparam>
		/// <param name="func">等待当前对象成功后执行的内容</param>
		/// <returns>返回整个方法链最终的成功失败结果</returns>
		// Token: 0x06000117 RID: 279 RVA: 0x00005BD8 File Offset: 0x00003DD8
		public OperateResult<TResult1, TResult2, TResult3, TResult4, TResult5, TResult6, TResult7> Then<TResult1, TResult2, TResult3, TResult4, TResult5, TResult6, TResult7>(Func<T, OperateResult<TResult1, TResult2, TResult3, TResult4, TResult5, TResult6, TResult7>> func)
		{
			return base.IsSuccess ? func(this.Content) : OperateResult.CreateFailedResult<TResult1, TResult2, TResult3, TResult4, TResult5, TResult6, TResult7>(this);
		}

		/// <summary>
		/// 指定接下来要做的是内容，当前对象如果成功，就返回接下来的执行结果，如果失败，就返回当前对象本身。<br />
		/// Specify what you want to do next, return the result of the execution of the current object if it succeeds, and return the current object itself if it fails.
		/// </summary>
		/// <typeparam name="TResult1">泛型参数一</typeparam>
		/// <typeparam name="TResult2">泛型参数二</typeparam>
		/// <typeparam name="TResult3">泛型参数三</typeparam>
		/// <typeparam name="TResult4">泛型参数四</typeparam>
		/// <typeparam name="TResult5">泛型参数五</typeparam>
		/// <typeparam name="TResult6">泛型参数六</typeparam>
		/// <typeparam name="TResult7">泛型参数七</typeparam>
		/// <typeparam name="TResult8">泛型参数八</typeparam>
		/// <param name="func">等待当前对象成功后执行的内容</param>
		/// <returns>返回整个方法链最终的成功失败结果</returns>
		// Token: 0x06000118 RID: 280 RVA: 0x00005BF6 File Offset: 0x00003DF6
		public OperateResult<TResult1, TResult2, TResult3, TResult4, TResult5, TResult6, TResult7, TResult8> Then<TResult1, TResult2, TResult3, TResult4, TResult5, TResult6, TResult7, TResult8>(Func<T, OperateResult<TResult1, TResult2, TResult3, TResult4, TResult5, TResult6, TResult7, TResult8>> func)
		{
			return base.IsSuccess ? func(this.Content) : OperateResult.CreateFailedResult<TResult1, TResult2, TResult3, TResult4, TResult5, TResult6, TResult7, TResult8>(this);
		}

		/// <summary>
		/// 指定接下来要做的是内容，当前对象如果成功，就返回接下来的执行结果，如果失败，就返回当前对象本身。<br />
		/// Specify what you want to do next, return the result of the execution of the current object if it succeeds, and return the current object itself if it fails.
		/// </summary>
		/// <typeparam name="TResult1">泛型参数一</typeparam>
		/// <typeparam name="TResult2">泛型参数二</typeparam>
		/// <typeparam name="TResult3">泛型参数三</typeparam>
		/// <typeparam name="TResult4">泛型参数四</typeparam>
		/// <typeparam name="TResult5">泛型参数五</typeparam>
		/// <typeparam name="TResult6">泛型参数六</typeparam>
		/// <typeparam name="TResult7">泛型参数七</typeparam>
		/// <typeparam name="TResult8">泛型参数八</typeparam>
		/// <typeparam name="TResult9">泛型参数九</typeparam>
		/// <param name="func">等待当前对象成功后执行的内容</param>
		/// <returns>返回整个方法链最终的成功失败结果</returns>
		// Token: 0x06000119 RID: 281 RVA: 0x00005C14 File Offset: 0x00003E14
		public OperateResult<TResult1, TResult2, TResult3, TResult4, TResult5, TResult6, TResult7, TResult8, TResult9> Then<TResult1, TResult2, TResult3, TResult4, TResult5, TResult6, TResult7, TResult8, TResult9>(Func<T, OperateResult<TResult1, TResult2, TResult3, TResult4, TResult5, TResult6, TResult7, TResult8, TResult9>> func)
		{
			return base.IsSuccess ? func(this.Content) : OperateResult.CreateFailedResult<TResult1, TResult2, TResult3, TResult4, TResult5, TResult6, TResult7, TResult8, TResult9>(this);
		}

		/// <summary>
		/// 指定接下来要做的是内容，当前对象如果成功，就返回接下来的执行结果，如果失败，就返回当前对象本身。<br />
		/// Specify what you want to do next, return the result of the execution of the current object if it succeeds, and return the current object itself if it fails.
		/// </summary>
		/// <typeparam name="TResult1">泛型参数一</typeparam>
		/// <typeparam name="TResult2">泛型参数二</typeparam>
		/// <typeparam name="TResult3">泛型参数三</typeparam>
		/// <typeparam name="TResult4">泛型参数四</typeparam>
		/// <typeparam name="TResult5">泛型参数五</typeparam>
		/// <typeparam name="TResult6">泛型参数六</typeparam>
		/// <typeparam name="TResult7">泛型参数七</typeparam>
		/// <typeparam name="TResult8">泛型参数八</typeparam>
		/// <typeparam name="TResult9">泛型参数九</typeparam>
		/// <typeparam name="TResult10">泛型参数十</typeparam>
		/// <param name="func">等待当前对象成功后执行的内容</param>
		/// <returns>返回整个方法链最终的成功失败结果</returns>
		// Token: 0x0600011A RID: 282 RVA: 0x00005C32 File Offset: 0x00003E32
		public OperateResult<TResult1, TResult2, TResult3, TResult4, TResult5, TResult6, TResult7, TResult8, TResult9, TResult10> Then<TResult1, TResult2, TResult3, TResult4, TResult5, TResult6, TResult7, TResult8, TResult9, TResult10>(Func<T, OperateResult<TResult1, TResult2, TResult3, TResult4, TResult5, TResult6, TResult7, TResult8, TResult9, TResult10>> func)
		{
			return base.IsSuccess ? func(this.Content) : OperateResult.CreateFailedResult<TResult1, TResult2, TResult3, TResult4, TResult5, TResult6, TResult7, TResult8, TResult9, TResult10>(this);
		}
	}
}
